package cs236369.webserver;

import java.util.LinkedList;

class Queue<T> {
	LinkedList<T> queueList;
	int capacity;
	int currentSize;
	
	Queue(int _size) {
		queueList = new LinkedList<T>();
		capacity = _size;
		currentSize = 0;
	}
	
	boolean enqueue(T element) {
		if (element != null && queueList != null && !full()) {
			queueList.add(element);
			currentSize ++;
			return true;
		}
		return false;
	}
	
	T dequeue()
	{
		if (currentSize > 0) {
			currentSize--;
			return queueList.remove(0);
		}
		return null;
	}
	
	boolean full() {
		if (currentSize == capacity){
			return true;
		}
		return false;
	}
	
	boolean empty() {
		if (currentSize == 0){
			return true;
		}
		return false;
	}
	
}
